package com.aspose.cells.b.a.b.e;

import com.aspose.cells.Color;
import com.aspose.cells.b.a.b.zo;
import com.aspose.cells.b.a.b.zq;
import com.aspose.cells.b.a.b.a.zh;
import com.aspose.cells.b.a.b.a.zi;
import java.awt.GradientPaint;
import java.awt.Paint;

public class zd implements zc {
   public Paint a(zh var1) {
      zq var2 = var1.a();
      float var3 = var2.f();
      float var4 = var2.g();
      float var5 = var2.f() + var2.h();
      float var6 = var2.g() + var2.i();
      com.aspose.cells.b.a.b.a.zc var7 = var1.m();
      if (var1.k() == null) {
         return this.a(var3, var4, var1.c(), var5, var6, var1.d(), var1.k());
      } else if (var1.b() != null) {
         zo[] var8 = this.a(var3, var4, 0.0F, var5, var6, 1.0F, var1.b());
         return new GradientPaint(var8[0].d(), var8[0].e(), var1.c().d(), var8[1].d(), var8[1].e(), var1.d().d(), var1.j());
      } else {
         return new GradientPaint(var3, var4, var1.c().d(), var5, var6, var1.d().d(), var1.j());
      }
   }

   private Paint a(float var1, float var2, Color var3, float var4, float var5, Color var6, Integer var7) {
      if (var7 == null) {
         return new GradientPaint(var1, var2, var3.d(), var4, var5, var6.d(), false);
      } else {
         zo[] var8;
         switch(var7) {
         case 0:
            return new GradientPaint(var1, var2, var3.d(), var4, var2, var6.d(), false);
         case 1:
            return new GradientPaint(var1, var2, var3.d(), var1, var5, var6.d(), false);
         case 2:
            var8 = this.a(var1, var2, var4, var5, true);
            return new GradientPaint(var8[0].d(), var8[0].e(), var3.d(), var8[1].d(), var8[1].e(), var6.d(), false);
         case 3:
            var8 = this.a(var1, var2, var4, var5, false);
            return new GradientPaint(var8[0].d(), var8[0].e(), var6.d(), var8[1].d(), var8[1].e(), var3.d(), false);
         default:
            return new GradientPaint(var1, var2, var3.d(), var4, var5, var6.d(), false);
         }
      }
   }

   private zo[] a(float var1, float var2, float var3, float var4, float var5, float var6, float var7) {
      float var8 = var4 - var1;
      float var9 = var5 - var2;
      zo var10 = new zo(var1 + var8 / 2.0F, var2 + var9 / 2.0F);
      float var11 = var8 * Math.abs((float)Math.cos((double)var7 * 3.141592653589793D / 180.0D)) + var9 * Math.abs((float)Math.sin((double)var7 * 3.141592653589793D / 180.0D));
      zo[] var12 = new zo[]{new zo(var10.d() - var11 / 2.0F + var11 * var3, var10.e()), new zo(var10.d() + var11 / 2.0F - var11 * (1.0F - var6), var10.e())};
      zi var13 = new zi();
      var13.a(var7, var10);
      var13.a(var12);
      return var12;
   }

   private zo[] a(float var1, float var2, float var3, float var4, boolean var5) {
      float var6 = var3 - var1;
      float var7 = var4 - var2;
      zo var8 = new zo(var1 + var6 / 2.0F, var2 + var7 / 2.0F);
      float var9 = (float)Math.atan2((double)var6, (double)var7);
      float var10 = var6 * (float)Math.cos((double)var9);
      if (!var5) {
         var9 = -var9;
      }

      zo[] var11 = new zo[]{new zo(var8.d() - var10, var8.e()), new zo(var8.d() + var10, var8.e())};
      zi var12 = new zi();
      var12.a(var9 * 57.29578F, var8);
      var12.a(var11);
      return var11;
   }
}
